package 动态规划;

/**
 * @ClassName _746使用最小费用怕楼梯
 * @Description TODO
 * @Author 昝亚杰
 * @Date 2021/12/29 20:46
 * Version 1.0
 **/
public class _746使用最小费用怕楼梯 {
    public int minCostClimbingStairs(int[] cost) {
        if(cost.length == 0 || cost == null){
            return 0;
        }
        int[]  dp = new int[cost.length];
        dp[0] = cost[0];
        dp[1] = cost[1];
        for(int i = 2; i < cost.length; i++){
            dp[i] = Math.min(dp[i - 1] + cost[i], dp[i - 2] + cost[i]);
        }
        return Math.min(dp[cost.length - 1],dp[cost.length - 2]);
    }
}
